package com.sfc.sdsr.activity;

import java.util.List;
import com.sfc.sdsr.R;
import com.sfc.sdsr.common.model.Song;
import com.sfc.sdsr.dao.DataToJava;
import com.sfc.sdsr.dao.SqliteDao;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

public class GloryBookActivity extends Activity {
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        DataToJava dataToJava = new DataToJava(this, "sfc.db", null, 3);
        SqliteDao sqliteDao = new SqliteDao(this, "sfc.db", null, 3);
        sqliteDao.setDataToJava(dataToJava);
        
        setContentView(R.layout.glorybook);
        
        List<Song> songs = sqliteDao.getSongs();
        
        // ------------------------------------------------------------------------------------------ //
        ViewGroup.LayoutParams viewGroupLayoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.gloryBookLayout);

        for (Song currentSong : songs) {
            TextView textView = new TextView(this);
            textView.setLayoutParams(viewGroupLayoutParams);
            textView.setText(currentSong.toString());
            textView.setTextColor(Color.WHITE);
            textView.setBackgroundColor(Color.DKGRAY);

            linearLayout.addView(textView);
        }
        // ------------------------------------------------------------------------------------------ //
    }

}
